package com.example.scaffold_demo;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.httplibrary.mvp.inject.InjectPresenter;
import com.example.scaffold_demo.base.BaseActivity;
import com.example.scaffold_demo.mvp.di.user.bean.UserInfoDateBean;
import com.example.scaffold_demo.mvp.di.user.contract.UserLoginContract;
import com.example.scaffold_demo.mvp.di.user.presenter.UserLoginPresenter;
import com.example.scaffold_demo.ui.DBActivity;
import com.example.scaffold_demo.ui.DownloadActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends BaseActivity implements UserLoginContract.View {

    @BindView(R.id.bt_network)
    Button btNetwork;
    @InjectPresenter
    public UserLoginPresenter mUserLoginPresenter;
    @BindView(R.id.bt_database)
    Button btDatabase;
    @BindView(R.id.bt_network_download)
    Button btNetworkDownload;


    @Override
    protected void initTitle() {

    }

    @Override
    protected int setLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void showError(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();

    }

    @Override
    public void dismissLoading() {

    }


    @Override
    public void toLoginSuccess(UserInfoDateBean msg) {
        Toast.makeText(this, msg.toString(), Toast.LENGTH_SHORT).show();
    }


    @OnClick({R.id.bt_network, R.id.bt_database, R.id.bt_network_download})
    public void onViewClicked(View view) {
        Intent mIntent;
        switch (view.getId()) {
            case R.id.bt_network:
                String black_box = "eyJvcyI6ImFuZHJvaWQiLCJ2ZXJzaW9uIjoiMy41LjMiLCJwcm9maWxlX3RpbWUiOjE2MywiaW50ZXJ2YWxfdGltZSI6MTY4MjQsInBhY2thZ2VzIjoiY29tLmhvb2xhaS5tb2VnbyIsImNzaWQiOiIxNTkyMzEzODc3NzQyNDQxNzQ4IiwidG9rZW5faWQiOiJKVElCQVlaclpcL1RSdmY5R1VyYTVwaHI5VEZCWW5HanJucmp0Y1dcLzdoRmxXRWdod2RjVWJacTJLTnN3Mnd4bFVtTUlHVlwvMk1XUWpTdnJRUUFldWJKdz09In0%3D";
                String phone = "15501149225";
                String passwd = "111111";
                mUserLoginPresenter.toLogin(black_box, phone, passwd);
                break;
            case R.id.bt_database:
                mIntent = new Intent(MainActivity.this, DBActivity.class);
                startActivity(mIntent);
                break;
            case R.id.bt_network_download:
                mIntent = new Intent(MainActivity.this, DownloadActivity.class);
                startActivity(mIntent);
                break;
        }
    }


}